package com.alex.consumer.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class UserController {

    @Resource
    RestTemplate restTemplate;

    @GetMapping("/buy")
    public String buyTicket(String name) {
        String ticket = restTemplate.getForObject("http://PROVIDER-TICKET/ticket", String.class);
//        String ticket = restTemplate.getForObject("http://provider-ticket/ticket", String.class);
//        String ticket = restTemplate.getForObject("http://localhost:8081/ticket", String.class);
        return name + "购买了: " + ticket;
    }
}
